###############################################################################
# REPLICATION FILES – Ageism and Politics Paper
# Last updated: February 1, 2026
# Author: Alonso Roman Amarales & Scott Williamson
###############################################################################

This folder contains all the replication materials for the paper:
"The Political Roots of Ageism in Greying Democracies"

It includes raw data, cleaned datasets, R scripts for IAT processing and coefficient plotting,
Stata do-files for data cleaning and regression analysis, and all final outputs.

Please read below for a description of each folder and how to run the replication.

===============================
1. v20250801_datasets
===============================
This folder contains the **raw survey data** collected in the United States, Italy, and South Korea.

Contents:
- Raw survey exports (in CSV format)
- Stata-ready versions of the same data (in DTA format)
- These are the inputs used in the Stata cleaning and regression scripts.

===============================
2. v20250801_R_Scripts
===============================
This folder contains two R scripts:

1. **IATgen_scores.R**  
   - Computes D-scores from the Implicit Association Test (IAT) using the `iatgen` package.
   - Outputs cleaned individual-level IAT scores, one file per country.
   - These files are then merged and used in the regression analysis (in Stata).
   - ➡️ You must set your `base_path` at the top of the script to match your file structure.

2. **Coef_plots_v20250802.R**  
   - Loads regression output files and creates coefficient plots (Figures 1, 2 and D6).
   - Focuses on models that include generational and personal grievances and ethnocentrism.
   - ➡️ You must set the correct `path` and `plot_dir` at the top of the script.

===============================
3. v20250801_dofiles
===============================
This folder contains all **Stata do-files** for cleaning, analysis, and result export.

Contents:
- Cleaning scripts: load and process the raw data from `v20250801_datasets`
- Analysis scripts: run the main regressions and robustness checks
- Export scripts: export results to CSV/LaTeX for use in plotting or tables
- **0_master.do**: runs all scripts in order.

➡️ Before running, **set the correct global path** at the top of `master.do` so it works on your machine.

===============================
4. Output
===============================
This folder contains all **final outputs**, organized by type:

- Cleaned datasets (after IAT + survey merging)
- Regression results (in CSV and LaTeX format)
- Coefficient plots (as PNG files)

These outputs can be directly used to reproduce all figures and tables in the paper.

===============================
REQUIREMENTS
===============================
To run the replication, you will need:

- **R (>= 4.0)** with `tidyverse`, `readr`, and `iatgen` installed
- **Stata 15 or later**
- Basic ability to edit file paths in R and Stata scripts

===============================
CONTACT
===============================
If you encounter issues running the replication, please contact:
The editorial team
